/**
 * 
 */
package com.ao.andou.db;

import android.content.ContentValues;
import android.content.Context;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;

import com.ao.andou.AppConstant;

/**
 * @author pentiumao
 *
 */
public class AndouDAO {

    /* sqlite */
    private SQLiteDatabase mSqlite;
    
    /**
     * Constructor
     * @param context Application context
     */
    public AndouDAO(Context context){
        // create database when is not exist
        AndouSqliteHelper helper = 
            new AndouSqliteHelper(context, AppConstant.DB_NAME, null, AppConstant.VERSION);
        mSqlite = helper.getWritableDatabase(); 
    }
    
    /**
     * Create new account
     * @param user user value object
     * @return the row ID of the newly inserted row, or -1 if an error occurred
     */
    public long createAccount(ContentValues user){
        DatabaseUtils.InsertHelper inserHelper = 
            new DatabaseUtils.InsertHelper(mSqlite, AppConstant.T_ACCOUNT);
        return inserHelper.insert(user);
    }
}
